package org.mayanjun.code.dalint.sharding;

import org.mayanjun.code.dalmeta.annotation.Column;
import org.mayanjun.code.dalmeta.annotation.Index;
import org.mayanjun.code.dalmeta.annotation.IndexColumn;
import org.mayanjun.code.dalmeta.annotation.Table;
import org.mayanjun.code.dalmeta.entity.EntityBean;
import org.mayanjun.code.dalmeta.enums.DataType;

/**
 * ScaleOutMetadata
 *
 * @author mayanjun(23/09/2016)
 */
@Table(value = "t_scaleout_metadata",
		indexes = {
				@Index(value = "idx_systemId", columns = @IndexColumn("systemId")),
				@Index(value = "idx_entityName", columns = @IndexColumn("entityName"))
		},
		comment = "分库分表规则元数据")
public class ScaleOutMetadata extends EntityBean {

	/**
	 * 数据规模，或者数据ID，表示的是一个阶梯
	 */
	@Column(type = DataType.BIGINT, comment = "数据规模")
	private Long scale;
	@Column(type = DataType.VARCHAR, length = "32", comment = "系统标识")
	 private String systemId;
	/**
	 * 各个实体的分库分表规则可以不同，用该值来标记一个实体, 建议存储实体类的 CanonicalName
	 */
	@Column(type = DataType.VARCHAR, length = "64", comment = "实体名称")
	private String entityName;
	/**
	 * 存储一个数据库名称和表名称的矩阵数据，以JSON格式存储
	 */
	@Column(type = DataType.MEDIUMTEXT, comment = "分库分表名称矩阵")
	private String matrixJson;

	public ScaleOutMetadata() {
	}

	public ScaleOutMetadata(Long id) {
		super(id);
	}

	public ScaleOutMetadata(Long scale, String entityName, String matrixJson) {
		this.scale = scale;
		this.entityName = entityName;
		this.matrixJson = matrixJson;
	}

	public Long getScale() {
		return scale;
	}

	public void setScale(Long scale) {
		this.scale = scale;
	}

	public String getEntityName() {
		return entityName;
	}

	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}

	public String getMatrixJson() {
		return matrixJson;
	}

	public void setMatrixJson(String matrixJson) {
		this.matrixJson = matrixJson;
	}

	public String getSystemId() {
		return systemId;
	}

	public void setSystemId(String systemId) {
		this.systemId = systemId;
	}
}
